import { defineStore } from 'pinia'
import { User } from '@/custom-types'
import { storeIds } from './ids'


console.log('store创建了')

export const useUserStore = defineStore(storeIds.user, {
  state: () => (
    { 
      user: <User>{} 
    }
  ),
  actions: {
    login(data: User) {
      console.log('登录', data)
      this.user = data
    },
    logout() {
      console.log('退出登录')
      // 重置状态为初始值
      this.$reset()
    }
  }
})